package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: RecordDetailBean
 * @Desciption: //记录列表数据bean
 * @author: zhangshihao
 * @date: 2018-09-25
 */
public class RecordDetailBean extends NetBaseBean {

    public int id;
    public int practice_type;
    public int resit_times;
    public int exercises_count;
    public int right_count;
    public String create_time;
    public String score;
    public int today_play_time;

    private List<PlayListBean> playListBeans = new ArrayList<>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        id = jsonObject.optInt("id",0);
        practice_type = jsonObject.optInt("practice_type",0);
        resit_times = jsonObject.optInt("resit_times",0);
        exercises_count = jsonObject.optInt("exercises_count",0);
        right_count = jsonObject.optInt("right_count",0);
        create_time = jsonObject.optString("create_time","");
        score = jsonObject.optString("score","");
        today_play_time = jsonObject.optInt("today_play_time",0);

        JSONArray playArr = jsonObject.optJSONArray("today_play_list");
        if(playArr != null && playArr.length() > 0){
            for(int i=0;i<playArr.length();i++){
                PlayListBean playBean = new PlayListBean();
                playBean.initByJson(playArr.optJSONObject(i));
                playListBeans.add(playBean);
            }
        }
    }

    public List<PlayListBean> getPlayListBeans() {
        return playListBeans;
    }

    public class PlayListBean extends NetBaseBean{

        public int id;
        public int paper_id;
        public String app_name;
        public String app_realname;
        public int child_id;
        public String duration;
        public int is_over;
        public double create_time;
        public double start_time;

        @Override
        public void initByJson(JSONObject jsonObject) throws JSONException {
            if(jsonObject == null){
                return;
            }

            id = jsonObject.optInt("id",0);
            paper_id = jsonObject.optInt("paper_id",0);
            app_name = jsonObject.optString("app_name","");
            app_realname = jsonObject.optString("app_realname","");
            child_id = jsonObject.optInt("child_id",0);
            duration = jsonObject.optString("duration","");
            is_over = jsonObject.optInt("is_over",0);
            create_time = jsonObject.optDouble("create_time",0);
            start_time = jsonObject.optDouble("start_time",0);
        }
    }

}
